<!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <% include("/view/console/common/css.html"){}	%>

 <title></title>
 </head>
 <body>
 <div class="zq-form">
 <form name="wnMachineDevice_form"  id="wnMachineDevice_form" class="form-horizontal" style="margin-bottom: 70px;">
   <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">设备号</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="deviceNumber" id="deviceNumber" class="form-control" check-type="required" value='${wnMachineDevice.deviceNumber!}' >
 </div>
  </div>
<!-- <div class="form-group">
 <label class="control-label col-sm-2 col-xs-2">设备类型</label>
 <div class="col-sm-6 col-xs-6">
 	<select class="form-control" id="deviceType"
 		name="deviceType" check-type="required">
 </select>
 </div>
 </div>-->
 <div class="form-group">
 <label class="control-label col-sm-2 col-xs-2">所属农场</label>
 <div class="col-sm-6 col-xs-6">
 	<select class="form-control" id="farmId"
 		name="farmId" check-type="required">
 </select>
 </div>
 </div>
 
   <input type='hidden' name='id' id='id' value='${wnMachineDevice.id!}'><input type='hidden' name='common_token' id='common_token' value='${common_token!}'>
 </form>
  <nav class="navbar navbar-default navbar-fixed-bottom" style="text-align: right">
    <a href="#" class="btn btn-success" style="margin:10px"  onclick='saveZqForm()'>保存 </a>
  </nav>
 </div>
 <% include("/view/console/common/js.html"){} 	%>
 <script type='text/javascript' src='/view/console/wnMachineDevice/wnMachineDeviceForm.js'></script>
 <script>

     layui.use(['layer','laydate'], function(){

     });
     $(function($) {
      /*开启表单验证*/
         $("#wnMachineDevice_form").validation();
      /*   componentSelectInit(
             {
                 ctxPath:'',
                 tableName:"sys_dictionary",
                 showValueField:"name",
                 valueField:"value",
                 selectId:"deviceType"  ,
                 where:" where code ='device_type' "
             }
             ,function(){
             });*/
         componentSelectInit(
             {
                 ctxPath:'',
                 tableName:"wn_farm",
                 showValueField:"name",
                 valueField:"id",
                 selectId:"farmId"  ,
                 where:""
             }
             ,function(){
                 $("#farmId").val('${wnMachineDevice.farmId!}');
             });

     });
     /*保存*/
     function saveZqForm(){
         if ($("#wnMachineDevice_form").valid() == false) {
             return false;
         }
         var formObject=new Object();
         formObject.deviceNumber=$('#deviceNumber').val()==''?null:$('#deviceNumber').val();
         formObject.deviceType="windows_auto_machine";
         formObject.farmId=$('#farmId').val()==''?null:$('#farmId').val();
         formObject.id=$('#id').val()==''?null:$('#id').val();

         var formObjectJson = JSON.stringify(formObject);
         zqPost("/console/wn_machine_device/save",
             {
                 formObjectJson :formObjectJson,
                 machineId:"${machineId!}",
                 common_token :$("#common_token").val()
             }, function(data) {
                 layer.alert(data.message, {skin: 'layui-layer-molv',closeBtn: 0 }, function(){
                     parent.$("#wnMachineDevice").bootstrapTable("refresh");
                     parent.layer.closeAll();
                 });

             });
     }
 </script>
 </body>
